package test;

import model.Admin;
import view.AdminView;
import view.BusinessView;
import view.impl.AdminViewImpl;
import view.impl.BusinessViewImpl;

import java.util.Scanner;

public class ElemeAdminSysterm {
    public static void main(String[] args) {
        AdminView adminView = new AdminViewImpl();
        BusinessView businessView = new BusinessViewImpl();
        System.out.println("---- 欢迎使用饿了么管理员后台系统 ----");
        Admin admin= null;
        int n = 0;
        while (true) {
            admin = adminView.login();
            if (admin == null) {
                n++;
                if (n == 1) {
                    System.out.println("账号密码错误，请重新登录。还有3次机会");
                }
                if (n ==2) {
                    System.out.println("账号密码错误，请重新登录。还有2次机会");
                }
                if (n ==3) {
                    System.out.println("账号密码错误，请重新登录。还有1次机会");
                }
            } else {
                break;
            }

            if (n == 4) {
                System.out.println("已经错误3次，系统自动退出。");
                return;
            }
        }
        Scanner sc=new Scanner(System.in);
        while (true){
            System.out.println("---- 请选择服务项目 ----");
            System.out.println("1.所有商家列表\n2.搜索商家\n3.新建商家\n4.删除商家\n5.退出系统");
            n= Integer.parseInt(sc.nextLine());
            if(n==1){
                businessView.listBusinessAll();
            }else if(n==2){
                businessView.listBusiness();
            }else if(n==3){
                businessView.saveBusiness();
            }else if(n==4){
                businessView.removeBusiness();
            }else if(n==5){
                System.out.println("谢谢使用。");
                break;
            }else{
                System.out.println("输入错误，请重新输入。");
            }
        }
    }
}

